package com.zcxy.fast.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zcxy.fast.bean.EntityValid;
import com.zcxy.fast.bean.PageQuery;
import com.zcxy.fast.bean.ReqParam;
import com.zcxy.fast.bean.Response;
import com.zcxy.fast.entity.SysUser;
import com.zcxy.fast.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 平台用户表 前端控制器
 * </p>
 *
 * @author zcc
 * @since 2019-10-11
 */
@RestController
@RequestMapping("/fast-api/sys-user")
@Api(tags = "平台-用户表管理")
@Slf4j
@Validated
public class SysUserController {

    @Autowired
    private ISysUserService iSysUserService;


    @ApiOperation(value = "(平台-用户表)数据新增")
    @PostMapping("/addUser")
    public Response addSysUser(@RequestBody  ReqParam<SysUser> sysUser) {
        iSysUserService.addUser(sysUser.getT());
        return Response.ok();
    }


    @ApiOperation(value = "(平台-用户表)数据更新")
    @PostMapping("/updateUser")
    public Response updateSysUser(@RequestBody  ReqParam<SysUser> sysUser) {
        iSysUserService.updateUser(sysUser.getT());
        return Response.ok();
    }


    @ApiOperation(value = "(平台-用户表)获取分页数据")
    @PostMapping("/getList")
    public Response<IPage<SysUser>> getList(@RequestBody PageQuery<SysUser> sysUserPageQuery) {
        return Response.ok( iSysUserService.getList(sysUserPageQuery));
    }


    @ApiOperation(value = "根据登录名称获取相关数据")
    @PostMapping("/getSysUserByLoginName")
    public Response<SysUser> getSysUserByLoginName(String loginName){
      return Response.ok(iSysUserService.getSysUserByLoginName(loginName));
    }

}
